package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	"xinyuan/copy/models"
)

type WebController struct {
	beego.Controller
}

func (this *WebController) Login() {
	this.TplName = "login.html"
}

func (this *WebController) Board() {
	uid := this.GetString("uid")
	beego.Info("uid:", uid)
	if uid == "" {
		this.TplName = "login.html"
		return
	}
	this.Data["uid"] = uid
	var itemList []*models.Item
	o := orm.NewOrm()
	qs := o.QueryTable(new(models.Item))
	c, e := qs.Filter("uid", uid).OrderBy("-create_time").All(&itemList)
	if e != nil {
		beego.Info(e.Error())
	} else {
		beego.Info("count:", c)
		this.Data["list"] = itemList
	}
	this.TplName = "board.html"
}
